import App from './App'
import Vue from 'vue'
import uView from "uview-ui";
import store from '@/store';
import tabBar from '@/components/tabbar'
Vue.config.productionTip = false
App.mpType = 'app'

let vuexStore = require("@/store/$u.mixin.js");
import $date from "@/common/date.js";
import $user from "@/common/getuserinfo.js";
// #ifdef H5
var jWeixin = require('jweixin-module');
Vue.prototype.jWeixin = jWeixin;
// #endif

// jWeixin.ready(function(){
//     // TODO
// });
Vue.prototype.date = $date;
Vue.prototype.user = $user;
Vue.mixin(vuexStore);
Vue.use(uView);
Vue.component('tab-bar', tabBar)

const app = new Vue({
	store,
	...App
})

import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)

import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
import $Api from '@/common/$api.js'
Vue.use($Api, app)
Vue.prototype.user = function() {
	return new Promise((resolve, reject) => {
		// #ifdef MP-TOUTIAO
		uni.getUserProfile({
			desc: '获取用户信息',
			success: (res) => {
				let data = {
					avatarUrl: res.userInfo.avatarUrl,
					gender: res.userInfo.gender,
					nickName: res.userInfo.nickName
				}

				resolve(data)

			},
			fail: (err) => {
				reject(err)
			}
		})
		// #endif
	})

}

app.$mount()
